package cn.lanqiao.springbootproject.service;

import cn.lanqiao.springbootproject.mapper.UserMapper;
import cn.lanqiao.springbootproject.mapper.UserRoleMapper;
import cn.lanqiao.springbootproject.vo.QueryUserVO;
import cn.lanqiao.springbootproject.vo.UserRoleVO;
import cn.lanqiao.springbootproject.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional
@Service
public class UserService {

    @Autowired
    UserMapper userMapper;

    @Autowired
    UserRoleMapper userRoleMapper;

    public void insert(UserRoleVO userRoleVO){
        userMapper.insert(userRoleVO); // userId = 44
        userRoleMapper.insert(userRoleVO.getUserId(),userRoleVO.getRoleId());
    }

    public UserRoleVO userLogin(QueryUserVO queryUserVO){
        return userMapper.userLogin(queryUserVO);
    }

    public List<UserVO> queryUserList(){
        return userMapper.queryUserList();
    }

}
